package gridmapper;

public class RobotData {

	// Global Variables
	public final int distanceNorth;
	public final int distanceEast;
	public final int distanceWest;
	public final int distanceSouth;
	public final int compassValue;
	public final int heading;
	public static final int ERROR_VALUE = -1;
	private static final int MIN_DISTANCE = 75;

	public RobotData(int northReading, int eastReading, int westReading,
			int southReading, int currentDirection, int compassReading) {
		this.distanceNorth = northReading;
		this.distanceEast = eastReading;
		this.distanceWest = westReading;
		this.distanceSouth = southReading;

		if (compassReading >= 0 && compassReading <= 360) {
			this.compassValue = compassReading;
		} else {
			this.compassValue = ERROR_VALUE;
		}

		if (currentDirection >= 0 && currentDirection <= 360) {
			this.heading = currentDirection;
		} else {
			this.heading = ERROR_VALUE;
		}
	}

	public boolean isErrorFree() {
		return distanceNorth != ERROR_VALUE && distanceEast != ERROR_VALUE
				&& distanceWest != ERROR_VALUE && distanceSouth != ERROR_VALUE
				&& compassValue != ERROR_VALUE && heading != ERROR_VALUE;
	}

	public static boolean isObstacle(int distance) {
		return distance < MIN_DISTANCE;
	}
}
